home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 158 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.8 KB

  1. From: "Eugene Radchenko" <eugene@qsar.chem.msu.su>
  2. Message-ID: <ACVI83na99@qsar.chem.msu.su>
  3. X-Original-Date: Mon, 29 Jan 1996 11:26:07 +0300 (MSK)
  4. Path: in2.uu.net!bounce-back
  5. Date: 29 Jan 96 10:38:37 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Organization: Lab. of Org.Synth., MSU
  9. X-Mailer: dMail [Demos Mail for DOS v1.23]
  10. Subject: Observations on templates
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMQyjxuEDnX0m9pzZAQFW8wF/d+TMJ60/PEZ9sCf4zoa1yYUZJhy3hVYY
  13.     d5WGD00r/fF0HawY199GuHPrOeJmwyL5
  14.     =hVeI
  15.  
  16. Hi people!
  17. I want to share some thoughts on the template section of the (April) draft
  18. standard (BTW, is ASCII version of September one is available somewhere?
  19. Easily editable/reformattable version (e.g. WinWord or RTF) would be even
  20. better).
  21. Generally, I like it  very much. In fact while reading it I had that
  22. 'Here-is-what-I-longed-for' feeling which I last had (programming-wise)
  23. when reading Stroustroup's book 5 years ago. Some things I do not
  24. understand, however, and would like the committee members to provide
  25. 'rationale on demand' and explain what is the point of some finer points.
  26.  
  27. 1) Clause [temp.res] verse 1 requires that all types dependent on the
  28. template parameter must be qualified by 'typename' keyword - supposedly to
  29. allow checking the template syntax. But it does not help anything as _each_
  30. instance will have to be checked anyway:
  31.   e.g.
  32.      struct X {
  33.       static int A;
  34.       class B {  };
  35.      }
  36.      template <class T> class Y {
  37.       typename T::A *ap;     // error in Y<X> - T::A is not a type
  38.       T::B *bp;              // error - no 'typename'
  39.      }
  40. 2) Clause [temp.dep] verse 5 states that base class scope names hide the
  41. template parameter:
  42.     struct A { struct B{}; };
  43.     template <class B, class C> struct X : A {
  44.       B b;   //A's B
  45.     };
  46. However, as base class is the enclosing scope, I would intuitively expect
  47. anything related to the derived class (its template parameter, for
  48. instance) to hide its names. Moreover, we can use A::B to access A's B -
  49. while template parameter is now inaccessible. Also, base class definition
  50. may be inaccessible. Of course, you can change the temp. param. name - but
  51. anyway it is not nice.
  52. 3) Clause [temp.arg.explicit] verses 2-3 requires that for explicit arg in
  53. member template to be present it must be qualified by 'template' keyword,
  54. e.g.
  55.      X *p; p->template alloc<200>();
  56. But to use operator -> we need X class definition anyway - so we know that
  57. alloc() is a template. Thus this keyword is redundant and likely to be
  58. forgotten (if I am not mistaken, it is in fact missing from some examples
  59. in lib.locale section).
  60. 4) Clause [temp.deduct] verse 4. Why the conversions other than Derived* ->
  61. Base* are not allowed in template deduction (at least default conversions
  62. like char->int; user conversions would be even better)?
  63.  
  64.           Best regards                      Genie
  65.  
  66. PS. Am I the only one who does not like the current drift in the C++ syntax
  67. from symbolic (C-like)
  68.    int a[10];
  69. to verbose (Pascal-like)
  70.    var
  71.      a: array[0..9] of integer;
  72. way of expressing things? Why don't use, for instance, cast_d instead od
  73. dynamic_cast (ugh). Yeah, I know we are not using 10-cps terminals Richie
  74. (sp?) did, but anyway... (and it consumes compiler memory space :-)
  75.  
  76.  
  77. --
  78. --------------------------------------------------------------------
  79. Eugene V. Radchenko           Research associate, Computer Chemistry
  80. E-mail: eugene@qsar.chem.msu.su                Fax: +7-(095)939-0290 
  81. Ordinary mail:  Chair of Organic Chemistry, Department of Chemistry,
  82.                       Moscow State University, 119899 Moscow, Russia
  83. *****************  Disappearances are deceptive  *******************
  84. ---
  85. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  86.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  87.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  88.